package com.enation.app.shop.front.api.appcontroller;

import com.enation.app.base.core.model.Adv;
import com.enation.app.base.core.service.IAdvManager;
import com.enation.app.shop.component.gallery.model.GoodsGallery;
import com.enation.app.shop.component.gallery.service.IGoodsGalleryManager;
import com.enation.app.shop.core.goods.model.*;
import com.enation.app.shop.core.goods.model.support.ParamGroup;
import com.enation.app.shop.core.goods.service.*;
import com.enation.app.shop.core.member.model.Favorite;
import com.enation.app.shop.core.member.service.IFavoriteManager;
import com.enation.app.shop.core.member.service.IMemberCommentManager;
import com.enation.app.shop.core.order.model.Order;
import com.enation.app.shop.core.order.service.IOrderManager;
import com.enation.app.shop.front.api.commentagain.service.ICommentAgainManager;
import com.enation.app.shop.front.api.commentlike.entity.CommentLike;
import com.enation.app.shop.front.api.commentlike.service.ICommentLikeManager;
import com.enation.eop.sdk.utils.StaticResourcesUtil;
import com.enation.framework.action.JsonResult;
import com.enation.framework.context.webcontext.ThreadContextHolder;
import com.enation.framework.database.IDaoSupport;
import com.enation.framework.util.JsonResultUtil;
import com.enation.framework.util.StringUtil;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.text.DecimalFormat;
import java.util.*;

/**
 * 商品类
 */
@Scope("prototype")
@Controller
@RequestMapping("/app/goods")
public class GoodAppController {
    @Autowired
    private IGoodsManager goodsManager;
    @Autowired
    private IBrandManager brandManager;
    @Autowired
    private IGoodsCatManager goodsCatManager;
    @Autowired
    private IProductManager productManager;
    @Autowired
    private IMemberCommentManager memberCommentManager;
    @Autowired
    private IDaoSupport daoSupport;
    @Autowired
    private IGoodsGalleryManager goodsGalleryManager;
    @Autowired
    private IFavoriteManager favoriteManager;
    @Autowired
    private ICommentLikeManager commentLikeManager;
    @Autowired
    private ICommentAgainManager commentAgainManager;
    @Autowired
    private IOrderManager orderManager;
    @Autowired
    private IAdvManager advManager;


    protected final Logger logger = Logger.getLogger(getClass());

    protected HttpServletRequest getRequest(){
        return  ThreadContextHolder.getHttpRequest();
    }

    /**
     *  //得到热门商品
     * @return
     */
    @ResponseBody
    @RequestMapping("/gethotgood")
    public JsonResult getHotGoods()  {
        //参照类GoodsListTag
        // String catid =(String) params.get("catid");
        // String tagid = (String)params.get("tagid");
        //String goodsnum = (String)params.get("goodsnum");
        String catid=null;
        String tagid="1";
        String goodsnum="5";
        List<Map<String,Object>> goodsList  = goodsManager.listGoods(catid, tagid, goodsnum);
        List< Map<String, Object>> goodsSmalls = new ArrayList<Map<String, Object>>();
        for (Map<String,Object> good:goodsList) {
            Map<String, Object> goodsSmall=new HashMap<String, Object>();
            goodsSmall.put("goodsid", good.get("goods_id"));
            goodsSmall.put("price", good.get("price"));
            goodsSmall.put("name", good.get("name"));
            try {
                goodsSmall.put("thum", StaticResourcesUtil.transformPathapp(good.get("thumbnail").toString()));
            }catch (Exception e){
                goodsSmall.put("thum",null);
            }
            goodsSmall.put("buycount",good.get("buy_count"));
            goodsSmall.put("param",good.get("params"));
            goodsSmall.put("specs",good.get("specs"));
            int goodsid = Integer.parseInt(good.get("goods_id").toString());
            int count = memberCommentManager.getCommentsCount(goodsid);
            int count3 = memberCommentManager.getCommentsGradeCount(goodsid, 3);//好评数量
            if (count == 0) {
                goodsSmall.put("sup", "100%");
            } else {
                DecimalFormat df = new DecimalFormat("0%");
                float ab = (float) count3 / count;
                goodsSmall.put("sup", df.format(ab));
            }
            goodsSmalls.add(goodsSmall);
        }
        return JsonResultUtil.getObjectMessageJson(goodsSmalls, "得到热门商品");
    }

    /**
     * //得到全部商品
     * @return
     */
    @ResponseBody
    @RequestMapping("/getallgood")
    public JsonResult getAllGoods()  {
        //参照类GoodsListTag
        // String catid =(String) params.get("catid");
        // String tagid = (String)params.get("tagid");
        //String goodsnum = (String)params.get("goodsnum");
        String catid=null;
        String tagid=null;
        String goodsnum=null;
        List goodsList  = goodsManager.listGoods(catid, tagid, goodsnum);

        return JsonResultUtil.getObjectMessageJson(goodsList,"全部商品");
    }

    /**
     * //根据关键字搜索保险
     //sort 1：按推荐排序2：按新品排序3：价格升序4：价格降序5：销量升序6：销量降序默认1
     * @param keyword
     * @param brand
     * @param sort
     * @return
     */
    @ResponseBody
    @RequestMapping("/serachgood")
    public  JsonResult  serachGood(String keyword,
                                    Integer brand,
                                    Integer sort
                                  ){
        List<Goods> goodslist=null;
        String typeid="";
        if (!StringUtil.isEmpty(keyword)){
            if (keyword.equals("保险")) {
                typeid="69";
            }else if (keyword.equals("饲料")){
                typeid="65";
            }else if (keyword.equals("兽药")){
                typeid="66";
            }else{
                typeid=keyword;
            }
        }
        if (sort!=null){
            goodslist=goodsManager.getAllByType(typeid,sort,brand);
        }else {
            goodslist=goodsManager.getAllByType(typeid,null,brand);
        }
        List< Map<String, Object>> goodsSmalls = new ArrayList<Map<String, Object>>();
        for (Goods good:goodslist) {
            Map<String, Object> goodsSmall=new HashMap<String, Object>();
            goodsSmall.put("goodsid", good.getGoods_id());
            goodsSmall.put("price", good.getPrice());
            goodsSmall.put("name", good.getName());
            try {
                goodsSmall.put("thum", StaticResourcesUtil.transformPathapp(good.getThumbnail()));
            }catch (Exception e){
                goodsSmall.put("thum", null);
            }
            goodsSmall.put("buycount",good.getBuy_count());
            //goodsSmall.put("spec",good.getSpecs());
            if (good.getType_id()==69){
                goodsSmall.put("ishot","热销意外险");
                goodsSmall.put("productTypes",0);
            }else if(good.getType_id()==65){
                goodsSmall.put("ishot","热销饲料");
                goodsSmall.put("productTypes",1);
            }else{
                goodsSmall.put("ishot","热销兽药");
                goodsSmall.put("productTypes",2);
            }
            int goodsid = Integer.parseInt(good.getGoods_id().toString());
            int count = memberCommentManager.getCommentsCount(goodsid);
            int count3 = memberCommentManager.getCommentsGradeCount(goodsid, 3);//好评数量
            if (count == 0) {
                goodsSmall.put("sup", "100%");
            } else {
                DecimalFormat df = new DecimalFormat("0%");
                float ab = (float) count3 / count;
                goodsSmall.put("sup", df.format(ab));
            }
            goodsSmalls.add(goodsSmall);
        }
        return JsonResultUtil.getObjectMessageJson(goodsSmalls,"搜索保险");
    }

    /**
     * //首页获取推荐商品
     * @return
     */
    @ResponseBody
    @RequestMapping("/getRecommendedProducts")
    public  JsonResult  getbaoxianbybuycount(){
        List<Goods>  goodslist =goodsManager.getbaoxianbybuycount(69);//保险
        List<Goods>  goodslist1 =goodsManager.getbaoxianbybuycount(65);//饲料
        List<Goods>  goodslist2 =goodsManager.getbaoxianbybuycount(66);//兽药
        List list4=new ArrayList();
        Map map=new LinkedHashMap ();
        Map map1=new LinkedHashMap ();
        Map map2=new LinkedHashMap ();
        List list=new ArrayList();
        List list1=new ArrayList();
        List list2=new ArrayList();
        for (Goods good:goodslist) {
            Map<String, Object> goodsSmall=new HashMap<String, Object>();
            goodsSmall.put("goodsid", good.getGoods_id());
            goodsSmall.put("price", good.getPrice());
            goodsSmall.put("name", good.getName());
            goodsSmall.put("thum", StaticResourcesUtil.transformPathapp(good.getThumbnail()));
            goodsSmall.put("buycount",good.getBuy_count());
            goodsSmall.put("ishot","热销意外险");
            goodsSmall.put("productTypes",0);
            int goodsid = Integer.parseInt(good.getGoods_id().toString());
            int count = memberCommentManager.getCommentsCount(goodsid);
            int count3 = memberCommentManager.getCommentsGradeCount(goodsid, 3);//好评数量
            if (count == 0) {
                goodsSmall.put("sup", "100%");
            } else {
                DecimalFormat df = new DecimalFormat("0%");
                float ab = (float) count3 / count;
                goodsSmall.put("sup", df.format(ab));
            }
            list.add(goodsSmall);
        }
        for (Goods good:goodslist1) {
            Map<String, Object> goodsSmall1=new HashMap<String, Object>();
            goodsSmall1.put("goodsid", good.getGoods_id());
            goodsSmall1.put("price", good.getPrice());
            goodsSmall1.put("name", good.getName());
            goodsSmall1.put("thum",StaticResourcesUtil.transformPathapp(good.getThumbnail()));
            goodsSmall1.put("buycount",good.getBuy_count());
            goodsSmall1.put("param",good.getParams());
            goodsSmall1.put("productTypes",1);
            int goodsid = Integer.parseInt(good.getGoods_id().toString());
            int count = memberCommentManager.getCommentsCount(goodsid);
            int count3 = memberCommentManager.getCommentsGradeCount(goodsid, 3);//好评数量
            if (count == 0) {
                goodsSmall1.put("sup", "100%");
            } else {
                DecimalFormat df = new DecimalFormat("0%");
                float ab = (float) count3 / count;
                goodsSmall1.put("sup", df.format(ab));
            }
            list1.add(goodsSmall1);

        }
        for (Goods good:goodslist2) {
            Map<String, Object> goodsSmall2=new HashMap<String, Object>();
            goodsSmall2.put("goodsid", good.getGoods_id());
            goodsSmall2.put("price", good.getPrice());
            goodsSmall2.put("name", good.getName());
            goodsSmall2.put("thum",StaticResourcesUtil.transformPathapp( good.getThumbnail()));
            goodsSmall2.put("buycount",good.getBuy_count());
            goodsSmall2.put("param",good.getParams());
            goodsSmall2.put("productTypes",2);
            int goodsid = Integer.parseInt(good.getGoods_id().toString());
            int count = memberCommentManager.getCommentsCount(goodsid);
            int count3 = memberCommentManager.getCommentsGradeCount(goodsid, 3);//好评数量
            if (count == 0) {
                goodsSmall2.put("sup", "100%");
            } else {
                DecimalFormat df = new DecimalFormat("0%");
                float ab = (float) count3 / count;
                goodsSmall2.put("sup", df.format(ab));
            }
            list2.add(goodsSmall2);

        }
        map.put("name","精选保险");
        map.put("data",list);
        map1.put("name","精选饲料");
        map1.put("data",list1);
        map2.put("name","精选兽药");
        map2.put("data",list2);
        list4.add(map);
        list4.add(map1);
        list4.add(map2);
        return JsonResultUtil.getObjectMessageJson(list4, "根据精选不精选搜索");
    }


    /**
     * //ios分类
     * @return
     */
    @ResponseBody
    @RequestMapping("/getCatIos")
    public JsonResult getCatIos(){
        List<Cat> cat=goodsManager.selectAllBigCat(0);
        List list1=new ArrayList();
        for (Cat cat1:cat){
            Map map=new HashMap();
            map.put("onename",cat1.getName());
            Integer pid=cat1.getCat_id();
            List<Cat> ca2=goodsManager.selectAllBigCat(pid);
            List list2=new ArrayList();
            for (Cat cat2:ca2){
                Map map2=new HashMap();
                map2.put("secondname",cat2.getName());
                Integer catid=cat2.getCat_id();
                List<Cat> cats=goodsManager.selectAllBigCat(catid);
                List list3=new ArrayList();
                for (Cat cat3:cats){
                    Map map3=new HashMap();
                    map3.put("threeid",cat3.getCat_id());
                    map3.put("threename",cat3.getName());
                    map3.put("threeimg",StaticResourcesUtil.transformPathapp(cat3.getImage()));
                    list3.add(map3);
                }
                map2.put("three",list3);
                list2.add(map2);
          }
          map.put("one",list2);
          list1.add(map);
        }
        return JsonResultUtil.getObjectMessageJson(list1,"一级分类");
    }

    /**
     * //一级分类
     * @return
     */
    @ResponseBody
    @RequestMapping("/getOneCat")
    public JsonResult getOneCat(){
        List<Cat> cat=goodsManager.selectAllBigCat(0);
        List list=new ArrayList();
        for (Cat cat1:cat){
            Map map=new HashMap();
            map.put("catid",cat1.getCat_id());
            map.put("catname",cat1.getName());
            list.add(map);
        }
        return JsonResultUtil.getObjectMessageJson(list,"一级分类");
    }

    /**
     *  //子分类
     * @param parentcartid
     * @return
     */
    @ResponseBody
    @RequestMapping("/getChildrenCat")
    public JsonResult getChildrenCat(Integer parentcartid){
        List<Cat> cat=goodsManager.selectAllBigCat(parentcartid);
        List list=new ArrayList();
        for (Cat cat1:cat){
            Map map=new HashMap();
            Integer catid=cat1.getCat_id();
            map.put("secondid",catid);
            map.put("secondname",cat1.getName());
            List list1=new ArrayList();
            List<Cat> cats=goodsManager.selectAllBigCat(catid);
            for (Cat cat2:cats){
                Map map1=new HashMap();
                try {
                    map1.put("threeimg",StaticResourcesUtil.transformPathapp(cat2.getImage()));
                }catch (Exception e){
                    map1.put("threeimg",null);
                }
                map1.put("threeid",cat2.getCat_id());
                map1.put("threename",cat2.getName());
                list1.add(map1);
            }
            map.put("list",list1);
            list.add(map);
        }
        return JsonResultUtil.getObjectMessageJson(list,"子分类");
    }

    /**
     * //通过保险id得到保险
     * @param goodsid
     * @param userid
     * @return
     */
    @ResponseBody
    @RequestMapping("/getinsurancebyid")
    public  JsonResult  getInsurancebyid(Integer goodsid,Integer userid){
        List<Product> productList  = this.productManager.list(goodsid);
        Map detail=new HashMap();
        List<String> imgs=new ArrayList<String>();
        List<GoodsGallery> goodsGalleries=goodsGalleryManager.list(goodsid);
        for (GoodsGallery goodsGallery:goodsGalleries){
              imgs.add(StaticResourcesUtil.transformPathapp(goodsGallery.getThumbnail()));
        }
        Goods  goods =goodsManager.getGoods(goodsid);
        String goodname=goods.getName();
        detail.put("name",goodname);
        try {
            detail.put("thum",StaticResourcesUtil.transformPathapp(goods.getThumbnail()));
        }catch (Exception e){
            detail.put("thum", null);
        }
        detail.put("goodsid",goods.getGoods_id());
        detail.put("price",goods.getPrice());//销售价格
        detail.put("maprice",goods.getMktprice());//市场价格
        detail.put("maxcost",goods.getCost());//最高保额
        detail.put("buycount",goods.getBuy_count());//
        detail.put("expresfee","包邮");//快递费
        try {
            String introl=goods.getIntro();
            String introltemp=introl.substring(13,91);
            detail.put("introl",introltemp);
        }catch (Exception e){
            detail.put("introl",null);
        }
        List<GoodsParam> list=null;
        Map goodsdetail=new HashMap();
        if (goods.getType_id()==69||goods.getType_id()==70){
                detail.put("description","");
            if (goods.getType_id()==69){
                detail.put("producttype",0);//商业险
            }else if (goods.getType_id()==70){
                detail.put("producttype",4);//政策险
            }
            //0商业险  1 饲料  2  兽药  4政策险
        }else {
            ParamGroup[] paramList =GoodsTypeUtil.converFormString(goods.getParams());
            if (paramList==null){
                detail.put("producttype",2);
                goodsdetail.put("goodparams",null);
            }
            try {
                if (paramList==null){
                    detail.put("producttype",2);
                }
                for (ParamGroup paramGroup:paramList){
                    list=paramGroup.getParamList();
                }
                goodsdetail.put("goodparams",list);
                if (goods.getType_id()==65){
                    detail.put("producttype",1);
                }else if (goods.getType_id()==66){
                    detail.put("producttype",2);
                }
            }catch (Exception e){
                this.logger.error("数组下标越界",e);
            }
        }
        List<Map<String,Object>>  colist= memberCommentManager.getGoodsComments(goodsid,1);
        Map<String,Object>  map11=null;
        Map comment=new HashMap();
        try{
            for (int i=0;i<colist.size();i++){
                map11=colist.get(0);
            }
            if (map11==null){
                comment=null;
            }else {
                comment.put("commentid",map11.get("comment_id"));
                comment.put("uname",map11.get("uname"));
                String grade=map11.get("grade").toString();
                try {
                    comment.put("commentstar",map11.get("star"));
                }catch (Exception e){
                    comment.put("commentstar",2);
                }
                int uid=Integer.valueOf(map11.get("member_id").toString());
                List<Order> order=orderManager.getByUserIdAndStatus(uid,null);
                try {
                    for (Order order1:order){
//                        List<OrderItem> itemList =orderManager.listGoodsItems(order1.getOrder_id());
//                        for (OrderItem orderItem:itemList){
//                            if (goodsid==orderItem.getGoods_id()){
//
//                            }
//                        }
                        Long buytime=order1.getOrdertime();
                        comment.put("buytime",buytime);
                    }
                }catch (Exception e){

                }
                try {
                    comment.put("face",StaticResourcesUtil.transformPathapp(map11.get("face").toString()));
                }catch (Exception e){
                    comment.put("face",null);
                }
                Long i=Long.valueOf(map11.get("dateline").toString());
                comment.put("commentdate",i*1000);
                comment.put("content",map11.get("content"));
                Integer commentid=Integer.parseInt(map11.get("comment_id").toString());
                List<Map<String, Object>> imglist=memberCommentManager.getCommentGalleryImg(commentid);
                List<String> commentimg=new ArrayList<String>();
                if (imglist==null){
                    comment.put("img",new ArrayList<String>());
                }else {
                    for (Map<String,Object> map:imglist){
                        String value=map.get("original").toString();
                        commentimg.add(StaticResourcesUtil.transformPathapp(value));
                    }
                    comment.put("img",commentimg);
                }
                comment.put("goodsname",goodname);
                Integer commentagain= commentAgainManager.getCount(commentid);
                Integer like= commentLikeManager.count(commentid);
                comment.put("like",like);
                comment.put("commentagain",commentagain);
                CommentLike commentLike=commentLikeManager.getByUseridAndCommentId(userid,commentid,goodsid);
                if (commentLike==null){
                    comment.put("thisuserlike",false);
                }else {
                    if (commentLike.getStatus()==2){
                        comment.put("thisuserlike",false);
                    }else {
                        comment.put("thisuserlike",true);
                    }
                }
            }
        }catch (Exception e){
            this.logger.error("数组下标越界",e);
        }
        List<Product> productList1  = this.productManager.list(goodsid);
        List<Map<String,Object>> pdetail=new ArrayList<Map<String, Object>>();
        for (Product product:productList1) {
            Map map2 = new LinkedHashMap();
            map2.put("pid", product.getProduct_id());
            map2.put("price", product.getPrice());
            //map2.put("productSn", product.getSn());
            map2.put("spec", product.getSpecs());
            try {
                String specs=product.getSpecs();
                if (specs.equals("3个月")){
                    map2.put("monthnumber",3);
                }else if (specs.equals("6个月")){
                    map2.put("monthnumber",6);
                }else if (specs.equals("9个月")){
                    map2.put("monthnumber",9);
                }else {
                    map2.put("monthnumber",12);
                }
            }catch (Exception e){

            }
            pdetail.add(map2);
        }
        Favorite favorite=favoriteManager.get(goodsid,userid);
        if (favorite==null){
            goodsdetail.put("collect",0);
        }else {
            goodsdetail.put("collect",1);
        }
        int commentcount= memberCommentManager.getCommentsCount(goodsid);
        goodsdetail.put("imgs",imgs);
        goodsdetail.put("detail",detail);
        goodsdetail.put("specs",pdetail);
        goodsdetail.put("comment",comment);
        goodsdetail.put("commentcount",commentcount);
        return  JsonResultUtil.getObjectMessageJson(goodsdetail,"通过保险id得到保险");
    }


    /**
     * //得到所有品牌
     * @return
     */
    @ResponseBody
    @RequestMapping("/getallbrand")
    public JsonResult getallbrand(){
        List<Brand> brand=brandManager.list();
        List list=new ArrayList();
        for (Brand brand1:brand){
            Map map=new HashMap();
            map.put("brandid",brand1.getBrand_id());
            map.put("brandname",brand1.getName());
            list.add(map);
        }
        return JsonResultUtil.getObjectMessageJson(list,"得到所有品牌");
    }

    /**
     * //商品详情下面的推荐
     * @param type
     * @return
     */
    @ResponseBody
    @RequestMapping("/getgroom")
    public JsonResult getTuiJian(Integer type){
        Integer typetemp=1;
        if(type==0){
            typetemp=69;
        }else if (type==1){
            typetemp=65;
        }else if (type==2){
            typetemp=66;
        }else {
            typetemp=70;
        }
        List<Goods> goodslist1=goodsManager.getbaoxianbybuycount(typetemp);
        List<Map<String,Object>> list1=new ArrayList<Map<String, Object>>();
        for (Goods good:goodslist1) {
            Map<String, Object> goodsSmall1=new HashMap<String, Object>();
            goodsSmall1.put("goodsid", good.getGoods_id());
            goodsSmall1.put("price", good.getPrice());
            goodsSmall1.put("name", good.getName());
            goodsSmall1.put("thum", StaticResourcesUtil.transformPathapp(good.getThumbnail()));
            goodsSmall1.put("buycount",good.getBuy_count());
            goodsSmall1.put("param",good.getParams());
            if (type==0){
                goodsSmall1.put("productTypes",0);
                goodsSmall1.put("ishot","热销商业险");
            }else if (type==1){
                goodsSmall1.put("productTypes",1);
                goodsSmall1.put("ishot","热销饲料");
            }else if (type==2){
                goodsSmall1.put("productTypes",2);
                goodsSmall1.put("ishot","热销兽药");
            }else {
                goodsSmall1.put("productTypes",4);
                goodsSmall1.put("ishot","热销政策险");
            }
            int goodsid = Integer.parseInt(good.getGoods_id().toString());
            int count = memberCommentManager.getCommentsCount(goodsid);
            int count3 = memberCommentManager.getCommentsGradeCount(goodsid, 3);//好评数量
            if (count == 0) {
                goodsSmall1.put("sup", "100%");
            } else {
                DecimalFormat df = new DecimalFormat("0%");
                float ab = (float) count3 / count;
                goodsSmall1.put("sup", df.format(ab));
            }
            list1.add(goodsSmall1);
        }
        return JsonResultUtil.getObjectMessageJson(list1,"11");
    }


    /**
     * //广告呀商城首页
     * @return
     */
    @ResponseBody
    @RequestMapping("/getadvs")
    public JsonResult getAdvs(){
        List<Adv> advs=advManager.listAdv(12L);//查询首页广告acid为12
        if (advs==null){
            return JsonResultUtil.getErrorJson("查询出错");
        }
        List list=new ArrayList();
        for (Adv adv:advs){
            Map map=new HashMap();
            map.put("advname",adv.getAname());
            map.put("advimgurl",adv.getAtturl());
            map.put("targeturl",adv.getUrl());
            list.add(map);
        }
        return JsonResultUtil.getObjectMessageJson(list,"广告呀");
    }

    /**
     * //广告呀app首页
     * @return
     */
    @ResponseBody
    @RequestMapping("/getappindexadvs")
    public JsonResult getAdvappindexs(){
        List<Adv> advs=advManager.listAdv(14L);//查询app首页广告acid为14
        if (advs==null){
            return JsonResultUtil.getErrorJson("查询出错");
        }
        List list=new ArrayList();
        for (Adv adv:advs){
            Map map=new HashMap();
            map.put("advname",adv.getAname());
            map.put("advimgurl",adv.getAtturl());
            map.put("targeturl",adv.getUrl());
            list.add(map);
        }
        return JsonResultUtil.getObjectMessageJson(list,"广告呀");
    }

}
